$(function() {
  $(".login-form").on("submit", function(e) {
    e.preventDefault();
    $.ajax({
      url: "/login",
      method: "post",
      data: {
        username: $("input[name='username']").val(),
        password: $("input[name='password']").val()
      },
      success: function(data) {
        if (data.code == 0) {
          window.location.href = data.goto;
        }
      }
    });
  });
});
